define(["../common"], function() {
	var $form = $("#addCMForm");
	var addDoPath = g_firmDomain + "/companyMember/addDo/json";
	
	loadjs(["validator"],function() {
		$form.validator({
			fields: {
				userName: "required"
			},
			valid: function(form) {
				if (!$form.showMsg("请稍候...", 'load', true)) return;
				
				$.post(addDoPath, $form.serialize(), function(data) {
					if (data.status === 0) {
						$form.showMsg("添加成功...", 'pass');
						setTimeout(function() {
							location.href = g_firmDomain + "/companyMember/list";
						}, 1000); // 延时
						
					} else {
						$form.showMsg(data.message, 'error');
					}
				});
			}
		});
	});

	$("[id^='submitBt_']").click(function() {
		$form.trigger('validate');
	});
	
});

	